// 变量引入
@import './variable';

// rest 样式重置
* {
  // 必须加，为了兼容
  box-sizing: border-box;
  outline: none;
}

html {
  font-size: 13px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.2em;
  background: #f1f1f1;
  -webkit-font-smoothing:antialiased;
}

a {
  color: #999;
}

p {
  line-height: 1.5em;
}

// 网站色彩和字体定义
// colors (变量) 

@each $colorKey,$color in $colors {
  .text-#{$colorKey} {
    color: $color
  }
  .bg-#{$colorKey} {
    background-color: $color;
  }
}

// text align(工具类)
@each $var in (left, center, right) {
  .text-#{$var} {
    text-align: $var!important;
  }
}

// font size
@each $sizeKey,$size in $font-sizes {
  .fs-#{$sizeKey} {
    font-size: $size * $base-font-size;
  }
}

// 文本溢出省略且使用省略号
.text-ellipse {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
// 文本溢出省略且使用省略号(多行)
.text-ellipses{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
// 宽、高100%
.w-100{
  width: 100%;
}
.h-100{
  height: 100%;
}

// flex 通用flex布局样式定义
.d-flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

// 主轴和交叉轴方式
@each $key,$value in $flex-jc {
  .jc-#{$key} {
    justify-content: $value;
  }
}

@each $key,$value in $flex-ai {
  .ai-#{$key} {
    align-items: $value;
  }
}

.flex-1 {
  flex: 1;
}

.flex-grow-1 {
  flex-grow: 1;
}

// spacing 常用边距定义
@each $typeKey,$type in $spacing-types {
  /**
  * m-1 ** margin-1
  * .m-1 {
  *   margin: 0.25;
  * }
  */
  @each $sizeKey,$size in $spacing-sizes {
    .#{$typeKey}-#{$sizeKey} {
      #{$type}:$size * $spacing-base-size;
    }
  }
  /**
  * mx-1,my-1 ** 上下边距相等或左右边距相等
  * .mx-1 {
  *   margin-left: 0.25;
  *   margin-right: 0.25;
  * }
  */
  @each $sizeKey,$size in $spacing-sizes {
    .#{$typeKey}x-#{$sizeKey} {
      #{$type}-left:$size * $spacing-base-size;
      #{$type}-right:$size * $spacing-base-size;
    }
    .#{$typeKey}y-#{$sizeKey} {
      #{$type}-top:$size * $spacing-base-size;
      #{$type}-bottom:$size * $spacing-base-size;
    }
  }
  /**
  * mt-1 ** margin-top-1
  * .mt-1 {
  *   margin-top: 0.25;
  * }
  */
  @each $directionKey,$direction in $spacing-directions {
    @each $sizeKey,$size in $spacing-sizes {
      .#{$typeKey}#{$directionKey}-#{$sizeKey} {
        #{$type}-#{$direction}:$size * $spacing-base-size;
      }
    }
  }
}

// button
.btn{
  border: none;
  border-radius: 0.1538rem;
  // map-get($font-sizes, 'sm')获取变量$font-sizes里面的'sm'
  font-size: map-get($font-sizes, 'sm') * $base-font-size;
  padding: 0.2rem 0.6rem;
  &.btn-lg {
    display: flex;
    justify-content: center;
    align-items: center;
    i {
      color: map-get($colors,'primary');
      font-weight: bold;
      font-size: 1.5rem;
      margin-right: 0.5rem;
    }
    background: map-get($colors, 'white-1');
    border: 1px solid map-get($colors,'white-2');
    padding: 0.8rem 1rem;
    font-size: 1rem;
  }
}

// nav导航
.nav {
  display: flex;
  .nav-item {
    border-bottom: 3px solid transparent;
    padding-bottom: 0.2rem;
    &.active {
    color: map-get($colors, 'primary');
    border-bottom: 3px solid map-get($colors, 'primary');
    }
  }
  &.nav-inverse {
    .nav-item {
      color: map-get($colors, 'white');
      &.active {
        border-bottom-color: map-get($colors, 'white');
      }
    }
  }
}

// sprite 精灵图片（雪碧图）
.sprite {
  background: url(../images/index.png) no-repeat 0 0;
  background-size: 28.8462rem;
  display: inline-block;
  &.sprite-news {
    width: 1.7692rem;
    height: 1.5385rem;
    background-position:  63.546% 15.517%;
  }
  &.sprite-arrow {
    width: 0.7692rem;
    height: 0.7692rem;
    background-position:  38.577% 52.076%;
  }
}

// border
@each $dir in (top, right, bottom, left) {
  .border-#{$dir} {
    border-#{$dir}: 1px solid $border-color;
  }
}

// 展开收缩
.open {
  height: 4.4rem;
  overflow: hidden;
}